import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl

def f(x):
    #y = np.log2(x)
    y = 2**x
    return y

mpl.rcParams['font.family'] = 'SimHei'  
mpl.rcParams['axes.unicode_minus'] = False

# 创建一个图形窗口和一个 Axes 对象
fig, ax = plt.subplots()

plt.gcf().set_size_inches(7.5, 7.5)

# 设置坐标轴范围和刻度
ax.set_xlim([-10, 10])
ax.set_ylim([-10, 10])
ax.set_xticks(range(-10, 11))
ax.set_yticks(range(-10, 11))

# 隐藏右侧和上方的坐标轴
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)

# 将底部和左侧的坐标轴移到数据空间的原点处
ax.spines['left'].set_position(('data', 0))
ax.spines['bottom'].set_position(('data', 0))

# 设置坐标轴标签和标题
ax.set_xlabel('x')
ax.xaxis.set_label_coords(1.03, 0.52)
ax.set_ylabel('y')
ax.yaxis.set_label_coords(0.50, 1.03)
#ax.set_title('标准四象限坐标系')

# 添加网格线
ax.grid(True)

# 生成数据点
x = np.linspace(-10, 10, 100)
y = f(x)

# 绘制曲线
#ax.plot(x, y) 
# 绘制点
ax.plot(x, y, 'o') 

# 添加图例
ax.legend()

# 显示图像
plt.show()